<template>
	<view class="page">
		<movable-area class="move-box">
			<movable-view x="9999" y="500" class="move-item" direction="all" >
				<image class="icon" src="/static/image/index/qrcode_icon.png" mode="" @click="getscanCode"></image>
			</movable-view>
		</movable-area>
	</view>
</template>

<script>
	import {getUrlJson} from '@/utils/utils.js';
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			/**
			 * 扫码触发事件
			 */
			getscanCode: function() {
				let that = this;
				uni.scanCode({
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						let data = getUrlJson(res.result);
						console.log(getUrlJson(res.result));
						if(data.t == 'INDENT'){
							// 物料签收(送货单)
							uni.navigateTo({
								url: '/subcontractList/order/purchase/waitbill/express/detail/detail?id='+ data.id
							});
						}else if(data.t == 'PURCHASE'){
							// 采购详情(采购单)
							uni.navigateTo({
								url: '/subcontractList/order/purchase/waitbill/detail/detail?id='+ data.id
							});
						}
						else {
							uni.showToast({
								title: '暂不支持该类型二维码',
								icon: 'none',
								duration: 2000
							});
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		
	}
	.move-box{
		position: fixed;
		left: 20rpx;
		top: 20rpx;
		pointer-events: none;
		width: calc(100% - 40rpx);
		height: calc(100vh - 40rpx);
		z-index: 99;
		.move-item{
			width:100rpx;
			height:100rpx;
			background: rgba(0,0,0,0.5);
			border-radius: 100%;
			pointer-events:auto;
			.icon{
				display: block;
				margin:15%;
				width:70%;
				height:70%;
			}
		}
	}
</style>
